package com.wanmait.heating.service.impl;

import com.github.pagehelper.PageInfo;
import com.wanmait.heating.mapper.UserinfoMapper;
import com.wanmait.heating.pojo.Userinfo;
import com.wanmait.heating.service.UserinfoService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

@Service("userinfoService")
@Transactional(rollbackFor = Exception.class)
public class UserinfoServiceImpl implements UserinfoService {
    @Resource
    private UserinfoMapper userinfoMapper;


    @Override
    public void insert(Userinfo object) {
        userinfoMapper.insert(object);
    }

    @Override
    public void delete(Integer id) {

    }

    @Override
    public void delete(String ids) {

    }

    @Override
    public void update(Userinfo object) {

    }

    @Override
    public Userinfo findById(Integer id) {
        return userinfoMapper.selectByPrimaryKey(id);
    }

    @Override
    public List<Userinfo> findAll() {
        List<Userinfo> userinfoList = userinfoMapper.listUserinfos();
        return userinfoList;
    }

    @Override
    public PageInfo<Userinfo> findPage(int pageNum, int pageSize) {
        return null;
    }



    //根据电话查所有用户的信息
    @Override
    public Userinfo getUserinfoByPhone(String phone) {
        Userinfo userinfo = userinfoMapper.getUserByPhone(phone);
        return userinfo;
    }

    //查询用户是否存在
    @Override
    public Userinfo isExist(Userinfo userinfo) {

        Userinfo existUserifno = userinfoMapper.isExist(userinfo);
        return existUserifno;
    }

    //根据用户查询所有的信息
    @Override
    public void upDataById(Userinfo userinfo) {
         userinfoMapper.updateByPrimaryKeySelective(userinfo);
    }
}
